import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
import re

testCase = "DBshop0024_删除评价流程"
# 1.打开前台 登录
# firefox=openBrowser(url)
# firefox.find_element_by_link_text('登录').click()
# DBshopLogin(firefox,userName,password)
# #2.点击我的订单，已完成订单，点击尚未评价，编写商品评价“下次还是会回购”，点击“点击提交”按钮。
# firefox.find_element_by_link_text('我的订单').click()
# firefox.find_element_by_partial_link_text('交易完成').click()
# firefox.find_elements_by_link_text('尚未评价')[0].click()
# firefox.find_element_by_id('comment_body').send_keys('下次还是会回购')
# firefox.find_element_by_xpath('//button').click()


#3.打开后台 登录,点击 商品管理,商品评价
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,"商品管理","商品评价")
#，点击“编辑查看”，点击删除按钮
firefox.find_element_by_link_text('编辑查看').click()
firefox.find_element_by_xpath('//td[contains(.,"下次还是会回购")]/following-sibling::td[4]/a[2]').click()
firefox.switch_to.alert.accept()
time.sleep(3)
#断言

try:
    firefox.find_element_by_xpath('//td[contains(.,"下次还是会回购")]/following-sibling::td[4]/a[2]')
    writeLog("%s 测试不通过" % testCase)
    getPhoto(firefox)
except:
    writeLog("%s 测试通过" % testCase)

firefox.quit()